package com.songlanyun.modules.ship.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.validator.ValidatorUtils;
import com.songlanyun.modules.ship.model.dto.OrderPackageItemVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.ship.dao.OrderPackageItemDao;
import com.songlanyun.modules.ship.entity.OrderPackageItem;
import com.songlanyun.modules.ship.service.OrderPackageItemService;


@Service("orderPackageItemService")
public class OrderPackageItemServiceImpl extends ServiceImpl<OrderPackageItemDao, OrderPackageItem> implements OrderPackageItemService {

    @Override
    public OrderPackageItem create(OrderPackageItem entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.insert(entity);
        return entity;
    }

    @Override
    public OrderPackageItem modify(OrderPackageItem entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.updateById(entity);
        return entity;
    }

    @Override
    public void remove(Long id) {

    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderPackageItem> page = this.page(
                new Query<OrderPackageItem>().getPage(params),
                new QueryWrapper<OrderPackageItem>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<OrderPackageItem> loadOrderPackageItem(Long orderPackageId) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<OrderPackageItem>().eq(OrderPackageItem::getGoodsPackageId,orderPackageId));
    }

    @Override
    public List<OrderPackageItemVo> loadOrderPackageItemVos(Long orderPackageId) {
        return this.baseMapper.loadOrderPackageItemVos(orderPackageId);
    }
}
